﻿using System.Collections.Generic;
using System.ComponentModel;
using Zadani09.db.DAO;

namespace Zadani09.db.ODS
{
    [DataObject(true)]
    public class GalerieDataObject : DataObject
    {
        [DataObjectMethod(DataObjectMethodType.Select)]
        public List<Galerie> cti(string razeni)
        {
            List<Galerie> list = DAOTovarna.instance.getGalerieDAO().loadList(0, 0);

            if (list == null) list = new List<Galerie>();

            //sortnuti
            return list;
        }

        [DataObjectMethod(DataObjectMethodType.Select)]
        public List<Galerie> cti_s_vyhledavanim(string razeni, string hledano, string atribut)
        {
            List<Galerie> list = cti(razeni);
            List<Galerie> vrat = new List<Galerie>();

            foreach (Galerie jeden in list)
            {
                if (najdi(hledano, jeden, atribut))
                {
                    vrat.Add(jeden);
                }
            }

            return (vrat);
        }

        [DataObjectMethod(DataObjectMethodType.Select)]
        public List<Galerie> ctiJednu(int id)
        {
            List<Galerie> galerie = new List<Galerie>();

            Galerie gal = DAOTovarna.instance.getGalerieDAO().load(id.ToString());

            if (gal != null) galerie.Add(gal);

            return galerie;
        }

        [DataObjectMethod(DataObjectMethodType.Insert)]
        public void vloz(Galerie data)
        {
            DAOTovarna.instance.getGalerieDAO().create(data);
        }

        [DataObjectMethod(DataObjectMethodType.Delete)]
        public void smaz(Galerie data)
        {
            DAOTovarna.instance.getGalerieDAO().delete(data);
        }

        [DataObjectMethod(DataObjectMethodType.Update)]
        public void aktualizuj(Galerie data)
        {
            DAOTovarna.instance.getGalerieDAO().update(data);
        }

    }
}
